package cn.lsngo.manager;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.converter.PropertyConverter;

import java.util.List;

/**
 * @author : admin
 * @Title :
 * @date : 2021/12/21 18:42
 */
public class ElectricConvert implements PropertyConverter<List<ElectricDetailBean>, String> {

    @Override
    public List<ElectricDetailBean> convertToEntityProperty(String databaseValue) {
        if (databaseValue == null) return null;
        TypeToken<List<ElectricDetailBean>> typeToken = new TypeToken<List<ElectricDetailBean>>() {
        };
        return new Gson().fromJson(databaseValue, typeToken.getType());
    }

    @Override
    public String convertToDatabaseValue(List<ElectricDetailBean> entityProperty) {
        if (entityProperty == null) {
            return "";
        } else {
            return new Gson().toJson(entityProperty);
        }
    }
}
